<?
    if(empty($category->breadcrumbs)) {
        $title   = $category->name;
        $titleLink = "/products/index/{$category->id}/".APP::urlize($category->name);
        $submenu = $category->children;
    } else {
        $c = $category->breadcrumbs[0];
        $title   = $c->name;
        $titleLink = "/products/index/{$c->id}/".APP::urlize($c->name);
        $submenu = $c->children;
    }

?>
<h1><?= $this->link($title, $titleLink) ?></h1>
<?= $this->element('submenu', array(
    'data'   => $submenu,
    'label'  => 'name',
    'entity' => $category,
    'link'   => function($category) {
        return "/products/index/{$category->id}/".APP::urlize($category->name);
    },
    'select' => function($c, $category) {
        return $c->id == $category->id;
    }
)) ?>
<?= $this->element('product_list', array('products' => $products)) ?>